
package com.youlu.campus.admin.activity.controller;

import com.youlu.campus.activity.entity.ActivityLotteryConfigQueryVo;
import com.youlu.campus.activity.entity.ActivityLotteryConfigVo;
import com.youlu.campus.activity.service.ActivityLotteryConfigService;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 抽奖配置服务接口
 */
@RestController
@RequestMapping("/admin/lottery-config")
public class AdminActivityLotteryConfigController {

    @Autowired
    private ActivityLotteryConfigService activityLotteryConfigService;


    /**
     * 通过activityid 查询
     *
     * @param activityId
     * @return
     */
    @GetMapping("/find/activity")
    public QResult<ActivityLotteryConfigVo> findByActivityId(@RequestParam String activityId) {
        return QResult.success(activityLotteryConfigService.info(activityId));
    }

    /**
     * 更新抽奖配置
     */
    @PostMapping("/save")
    public QResult save(@RequestBody ActivityLotteryConfigVo configVo) {
        activityLotteryConfigService.save(configVo);
        return QResult.success(true);
    }

    /**
     * 删除抽奖配置
     */
    @PostMapping("/delete")
    public QResult save(@RequestBody ActivityLotteryConfigQueryVo query) {
        activityLotteryConfigService.delete(query.getId());
        return QResult.success(true);
    }
}
